<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>指定送货员</title>
	<meta name="decorator" content="default"/>
	<style type="text/css">
		.table-bordered {
			border-collapse: collapse;
			border-radius: 0px;
			margin-bottom: 10px;
		}
		.table td {
			vertical-align: middle;
			text-align: center;
			padding: 0px;
			margin: 0px;
			height: 30px;
		}
		.footer {
			position:fixed; bottom:0; background:#ABABAB; width:100%; height:35px; line-height:32px; z-index:9999; opacity:1;
			filter:alpha(opacity=60); _bottom:auto; _width:100%; _position:absolute;text-align: right;
			_top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-
			(parseInt(this.currentStyle.marginTop, 10)||0)-(parseInt(this.currentStyle.marginBottom, 10)||0)));
	    }
	</style>
	<script type="text/javascript">
		$(document).ready(function() {
			var nodeLen = $(".jbox-button-panel", top.document).length;
			$(".jbox-button-panel", top.document).eq(nodeLen-1).remove();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					error.insertAfter(element);
				}
			});
		});
		
		//设置送货员
		function setDeliveryPerson(){
			var memberId = $("#memberId").val();
			if(memberId == ""){
				showJBoxMess("请先选择派送员.","error");
				return;
			}
			//异步提交送货员设定
			loading("正在提交，请稍等...");
			$.ajax({
				type: 'get',
				url: '${ctx}/ivm/order/delivery/setDeliveryMember/save',
				data: "orderIds="+$("#orderIds").val()+"&memberId="+memberId,
				dataType: 'json',
				success: function(data){
					if(data.status==200){
						showJBoxMess(data.message,"success");
						setTimeout(function(){
							parent.mainFrame.location.reload();
							top.$.jBox.close();
						}, 1000);
					}else{
						showJBoxMess(data.message,"error");
					}
				},
				failure: function(){
					showJBoxMess("操作失败","error");
				}
			});
		}
	</script>
</head>
<body>
<div style="margin:10px 20px 50px 20px;">
	<form:form id="inputForm" method="post">
	<input type="hidden" id="orderIds" name="orderIds" value="${orderIds }"/>
	<tags:message content="${message}"/>
	<!-- 派送员信息 -->
	<ul class="wl-tab-nav">
		<li><span>送货员设置</span></li>
	</ul>
	<div class="delivery_info">
		<label>送货员:</label>
		<select id="memberId" class="required">
			<option value="">请选择</option>
			<c:forEach items="${fns:getDeliveryMemberList(1)}" var="member">
				<option value="${member.id }">${member.name }</option>
			</c:forEach>
		</select>
		
	</div>
	</form:form>
</div>
<div class="footer">
	<input class="btn btn-primary" type="button" onclick="setDeliveryPerson()" value="提交"/>
</div>
</body>
</html>